From: Aaron Schulz Date: Thu, 20 Oct 2011 00:43:43 +0000 (+0000) Subject: * Added a proper Pager::doBatchLookups() function X-Git-Tag: 1.31.0-rc.0~26992 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=ddaa5d800ec980f1e3e8a49ad228f324ebe5a7f2;p=lhc%2Fweb%2Fwiklou.git * Added a proper Pager::doBatchLookups() function * Made HistoryPager use a link batch via Pager::doBatchLookups() --- diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 8aa7b2b7d4..f4b888fbb4 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -382,6 +382,19 @@ class HistoryPager extends ReverseChronologicalPager { return $s; } + function doBatchLookups() { + # Do a link batch query + $this->mResult->seek( 0 ); + $batch = new LinkBatch(); + # Give some pointers to make (last) links + foreach ( $this->mResult as $row ) { + $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) ); + } + $batch->execute(); + $this->mResult->seek( 0 ); + } + /** * Creates begin of history list with a submit button * diff --git a/includes/Pager.php b/includes/Pager.php index 99dbd1c8e0..e4c2405587 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -325,10 +325,13 @@ abstract class IndexPager extends ContextSource implements Pager { * * @return String */ - function getBody() { + public function getBody() { if ( !$this->mQueryDone ) { $this->doQuery(); } + # Do any special query batches before display + $this->doBatchLookups(); + # Don't use any extra rows returned by the query $numRows = min( $this->mResult->numRows(), $this->mLimit ); @@ -384,13 +387,21 @@ abstract class IndexPager extends ContextSource implements Pager { ); } + /** + * Called from getBody(), before getStartBody() is called. This + * will be called even if there are no rows in the result set. + * + * @return void + */ + protected function doBatchLookups() {} + /** * Hook into getBody(), allows text to be inserted at the start. This * will be called even if there are no rows in the result set. * * @return String */ - function getStartBody() { + protected function getStartBody() { return ''; } @@ -399,7 +410,7 @@ abstract class IndexPager extends ContextSource implements Pager { * * @return String */ - function getEndBody() { + protected function getEndBody() { return ''; } @@ -409,7 +420,7 @@ abstract class IndexPager extends ContextSource implements Pager { * * @return String */ - function getEmptyBody() { + protected function getEmptyBody() { return ''; }